#include "AlarmCache.h"

#include "AlarmTypeDefine.h"

//获取上次告警时间的秒值(自Utc的1970-01-01T00:00:00.000开始的秒值)
quint64 SAlarmCache::GetSecsSinceEpoch()
{
    quint64 ulLastDt = 0;
    QDateTime dt = QDateTime(QDate(usYear, usMonth, usDay)
                             , QTime(usHour, usMin, usSec));

#if QT_VERSION >= QT_VERSION_CHECK(5,8,0)
    ulLastDt = dt.toSecsSinceEpoch();
#endif

    return ulLastDt;
}

//获取告警的字符串值(格式为yyyy-MM-dd HH:mm:ss)
QString SAlarmCache::GetDatetimeValue()
{
    QDateTime dt = QDateTime(QDate(usYear, usMonth, usDay)
                             , QTime(usHour, usMin, usSec));

    //yyyy-MM-dd HH:mm:ss
    return dt.toString("yyyy-MM-dd HH:mm:ss");
}

bool SAlarmCache::IsTypeOfWarn()
{
    static QSet<int> setTypes;
    if (setTypes.isEmpty())
    {
        setTypes
            //预警定义
            << ALARM_TYPE_BANK_VOL_UP_LIMIT_WARN //组端电压上限预警
            << ALARM_TYPE_BANK_VOL_DOWN_LIMIT_WARN //组端电压下限预警
            << ALARM_TYPE_CHG_CUR_UP_LIMIT_WARN //充电电流上限预警
            << ALARM_TYPE_DCHG_CUR_UP_LIMIT_WARN //放电电流上限预警
            << ALARM_TYPE_SGL_VOL_UP_LIMIT_WARN //单体电压上限预警
            << ALARM_TYPE_SGL_VOL_DOWN_LIMIT_WARN //单体电压下限预警
            << ALARM_TYPE_CHG_SGL_TEMP_UP_LIMIT_WARN //充电温度上限预警
            << ALARM_TYPE_CHG_SGL_TEMP_DOWN_LIMIT_WARN //充电温度下限预警
            << ALARM_TYPE_DCHG_SGL_TEMP_UP_LIMIT_WARN //放电温度上限预警
            << ALARM_TYPE_DCHG_SGL_TEMP_DOWN_LIMIT_WARN //放电温度下限预警
            << ALARM_TYPE_SGL_TEMP_UP_LIMIT_WARN //单体温度上限预警
            << ALARM_TYPE_SGL_TEMP_DOWN_LIMIT_WARN //单体温度下限预警
            << ALARM_TYPE_ENV_TEMP_UP_LIMIT_WARN //环境温度上限预警
            << ALARM_TYPE_ENV_TEMP_DOWN_LIMIT_WARN //环境温度下限预警
            << ALARM_TYPE_POWER_LINE_TEMP_UP_LIMIT_WARN //动力线温度上限预警
            << ALARM_TYPE_BANK_SOC_UP_LIMIT_WARN //组端SOC上限预警
            << ALARM_TYPE_BANK_SOC_DOWN_LIMIT_WARN //组端SOC下限预警
            << ALARM_TYPE_POS_RES_DOWN_LIMIT_WARN //正极绝缘内阻下限预警
            << ALARM_TYPE_NEG_RES_DOWN_LIMIT_WARN //负极绝缘内阻下限预警
            << ALARM_TYPE_PACK_VOL_DIFF_UP_LIMIT_WARN //箱压差上限预警
            << ALARM_TYPE_PACK_TEMP_DIFF_UP_LIMIT_WARN //箱温差上限预警
            << ALARM_TYPE_BANK_VOL_DIFF_UP_LIMIT_WARN //组压采集差上限预警
            << ALARM_TYPE_PACK_VOL_UP_LIMIT_WARN //箱电压上限预警
            << ALARM_TYPE_PACK_VOL_DOWN_LIMIT_WARN //箱电压下限预警
            << ALARM_TYPE_RESERVE1_WARN //保留1预警
            << ALARM_TYPE_RESERVE2_WARN //保留2预警
            << ALARM_TYPE_RESERVE3_WARN //保留3预警
            << ALARM_TYPE_RESERVE4_WARN //保留4预警
            << ALARM_TYPE_RESERVE5_WARN //保留5预警
            << ALARM_TYPE_RESERVE6_WARN //保留6预警
            ;
    }

    return setTypes.contains(usType);
}

bool SAlarmCache::IsTypeOfAlarm()
{
    static QSet<int> setTypes;
    if (setTypes.isEmpty())
    {
        setTypes
            //告警定义
            << ALARM_TYPE_BANK_VOL_UP_LIMIT_ALARM //组端电压上限告警
            << ALARM_TYPE_BANK_VOL_DOWN_LIMIT_ALARM //组端电压下限告警
            << ALARM_TYPE_CHG_CUR_UP_LIMIT_ALARM //充电电流上限告警
            << ALARM_TYPE_DCHG_CUR_UP_LIMIT_ALARM //放电电流上限告警
            << ALARM_TYPE_SGL_VOL_UP_LIMIT_ALARM //单体电压上限告警
            << ALARM_TYPE_SGL_VOL_DOWN_LIMIT_ALARM //单体电压下限告警
            << ALARM_TYPE_CHG_SGL_TEMP_UP_LIMIT_ALARM //充电温度上限告警
            << ALARM_TYPE_CHG_SGL_TEMP_DOWN_LIMIT_ALARM //充电温度下限告警
            << ALARM_TYPE_DCHG_SGL_TEMP_UP_LIMIT_ALARM //放电温度上限告警
            << ALARM_TYPE_DCHG_SGL_TEMP_DOWN_LIMIT_ALARM //放电温度下限告警
            << ALARM_TYPE_SGL_TEMP_UP_LIMIT_ALARM //单体温度上限告警
            << ALARM_TYPE_SGL_TEMP_DOWN_LIMIT_ALARM //单体温度下限告警
            << ALARM_TYPE_ENV_TEMP_UP_LIMIT_ALARM //环境温度上限告警
            << ALARM_TYPE_ENV_TEMP_DOWN_LIMIT_ALARM //环境温度下限告警
            << ALARM_TYPE_POWER_LINE_TEMP_UP_LIMIT_ALARM //动力线温度上限告警
            << ALARM_TYPE_BANK_SOC_UP_LIMIT_ALARM //组端SOC上限告警
            << ALARM_TYPE_BANK_SOC_DOWN_LIMIT_ALARM //组端SOC下限告警
            << ALARM_TYPE_POS_RES_DOWN_LIMIT_ALARM //正极绝缘内阻下限告警
            << ALARM_TYPE_NEG_RES_DOWN_LIMIT_ALARM //负极绝缘内阻下限告警
            << ALARM_TYPE_PACK_VOL_DIFF_UP_LIMIT_ALARM //箱压差上限告警
            << ALARM_TYPE_PACK_TEMP_DIFF_UP_LIMIT_ALARM //箱温差上限告警
            << ALARM_TYPE_BANK_VOL_DIFF_UP_LIMIT_ALARM //组压采集差上限告警
            << ALARM_TYPE_PACK_VOL_UP_LIMIT_ALARM //箱电压上限告警
            << ALARM_TYPE_PACK_VOL_DOWN_LIMIT_ALARM //箱电压下限告警
            << ALARM_TYPE_RESERVE1_ALARM //保留1告警
            << ALARM_TYPE_RESERVE2_ALARM //保留2告警
            << ALARM_TYPE_RESERVE3_ALARM //保留3告警
            << ALARM_TYPE_RESERVE4_ALARM //保留4告警
            << ALARM_TYPE_RESERVE5_ALARM //保留5告警
            << ALARM_TYPE_RESERVE6_ALARM //保留6告警
            ;
    }

    return setTypes.contains(usType);
}

bool SAlarmCache::IsTypeOfProt()
{
    static QSet<int> setTypes;
    if (setTypes.isEmpty())
    {
        setTypes
            //保护定义
            << ALARM_TYPE_BANK_VOL_UP_LIMIT_PROT //组端电压上限保护
            << ALARM_TYPE_BANK_VOL_DOWN_LIMIT_PROT //组端电压下限保护
            << ALARM_TYPE_CHG_CUR_UP_LIMIT_PROT //充电电流上限保护
            << ALARM_TYPE_DCHG_CUR_UP_LIMIT_PROT //放电电流上限保护
            << ALARM_TYPE_SGL_VOL_UP_LIMIT_PROT //单体电压上限保护
            << ALARM_TYPE_SGL_VOL_DOWN_LIMIT_PROT //单体电压下限保护
            << ALARM_TYPE_CHG_SGL_TEMP_UP_LIMIT_PROT //充电温度上限保护
            << ALARM_TYPE_CHG_SGL_TEMP_DOWN_LIMIT_PROT //充电温度下限保护
            << ALARM_TYPE_DCHG_SGL_TEMP_UP_LIMIT_PROT //放电温度上限保护
            << ALARM_TYPE_DCHG_SGL_TEMP_DOWN_LIMIT_PROT //放电温度下限保护
            << ALARM_TYPE_SGL_TEMP_UP_LIMIT_PROT //单体温度上限保护
            << ALARM_TYPE_SGL_TEMP_DOWN_LIMIT_PROT //单体温度下限保护
            << ALARM_TYPE_ENV_TEMP_UP_LIMIT_PROT //环境温度上限保护
            << ALARM_TYPE_ENV_TEMP_DOWN_LIMIT_PROT //环境温度下限保护
            << ALARM_TYPE_POWER_LINE_TEMP_UP_LIMIT_PROT //动力线温度上限保护
            << ALARM_TYPE_BANK_SOC_UP_LIMIT_PROT //组端SOC上限保护
            << ALARM_TYPE_BANK_SOC_DOWN_LIMIT_PROT //组端SOC下限保护
            << ALARM_TYPE_POS_RES_DOWN_LIMIT_PROT //正极绝缘内阻下限保护
            << ALARM_TYPE_NEG_RES_DOWN_LIMIT_PROT //负极绝缘内阻下限保护
            << ALARM_TYPE_PACK_VOL_DIFF_UP_LIMIT_PROT //箱压差上限保护
            << ALARM_TYPE_PACK_TEMP_DIFF_UP_LIMIT_PROT //箱温差上限保护
            << ALARM_TYPE_BANK_VOL_DIFF_UP_LIMIT_PROT //组压采集差上限保护
            << ALARM_TYPE_PACK_VOL_UP_LIMIT_PROT //箱电压上限保护
            << ALARM_TYPE_PACK_VOL_DOWN_LIMIT_PROT //箱电压下限保护
            << ALARM_TYPE_RESERVE1_PROT //保留1保护
            << ALARM_TYPE_RESERVE2_PROT //保留2保护
            << ALARM_TYPE_RESERVE3_PROT //保留3保护
            << ALARM_TYPE_RESERVE4_PROT //保留4保护
            << ALARM_TYPE_RESERVE5_PROT //保留5保护
            << ALARM_TYPE_RESERVE6_PROT //保留6保护
            ;
    }

    return setTypes.contains(usType);
}

bool SAlarmCache::IsTypeOfTip()
{
    static QSet<int> setTypes;
    if (setTypes.isEmpty())
    {
        setTypes
            //提示定义
            << ALARM_TYPE_BANK_VOL_UP_LIMIT_TIP //组端电压上限提示
            << ALARM_TYPE_BANK_VOL_DOWN_LIMIT_TIP //组端电压下限提示
            << ALARM_TYPE_CHG_CUR_UP_LIMIT_TIP //充电电流上限提示
            << ALARM_TYPE_DCHG_CUR_UP_LIMIT_TIP //放电电流上限提示
            << ALARM_TYPE_SGL_VOL_UP_LIMIT_TIP //单体电压上限提示
            << ALARM_TYPE_SGL_VOL_DOWN_LIMIT_TIP //单体电压下限提示
            << ALARM_TYPE_CHG_SGL_TEMP_UP_LIMIT_TIP //充电温度上限提示
            << ALARM_TYPE_CHG_SGL_TEMP_DOWN_LIMIT_TIP //充电温度下限提示
            << ALARM_TYPE_DCHG_SGL_TEMP_UP_LIMIT_TIP //放电温度上限提示
            << ALARM_TYPE_DCHG_SGL_TEMP_DOWN_LIMIT_TIP //放电温度下限提示
            << ALARM_TYPE_SGL_TEMP_UP_LIMIT_TIP //单体温度上限提示
            << ALARM_TYPE_SGL_TEMP_DOWN_LIMIT_TIP //单体温度下限提示
            << ALARM_TYPE_ENV_TEMP_UP_LIMIT_TIP //环境温度上限提示
            << ALARM_TYPE_ENV_TEMP_DOWN_LIMIT_TIP //环境温度下限提示
            << ALARM_TYPE_POWER_LINE_TEMP_UP_LIMIT_TIP //动力线温度上限提示
            << ALARM_TYPE_BANK_SOC_UP_LIMIT_TIP //组端SOC上限提示
            << ALARM_TYPE_BANK_SOC_DOWN_LIMIT_TIP //组端SOC下限提示
            << ALARM_TYPE_POS_RES_DOWN_LIMIT_TIP //正极绝缘内阻下限提示
            << ALARM_TYPE_NEG_RES_DOWN_LIMIT_TIP //负极绝缘内阻下限提示
            << ALARM_TYPE_PACK_VOL_DIFF_UP_LIMIT_TIP //箱压差上限提示
            << ALARM_TYPE_PACK_TEMP_DIFF_UP_LIMIT_TIP //箱温差上限提示
            << ALARM_TYPE_BANK_VOL_DIFF_UP_LIMIT_TIP //组压采集差上限提示
            << ALARM_TYPE_PACK_VOL_UP_LIMIT_TIP //箱电压上限提示
            << ALARM_TYPE_PACK_VOL_DOWN_LIMIT_TIP //箱电压下限提示
            << ALARM_TYPE_RESERVE1_TIP //保留1提示
            << ALARM_TYPE_RESERVE2_TIP //保留2提示
            << ALARM_TYPE_RESERVE3_TIP //保留3提示
            << ALARM_TYPE_RESERVE4_TIP //保留4提示
            << ALARM_TYPE_RESERVE5_TIP //保留5提示
            << ALARM_TYPE_RESERVE6_TIP //保留6提示
            ;
    }

    return setTypes.contains(usType);
}

bool SAlarmCache::IsTypeOfFault()
{
    static QSet<int> setTypes;
    if (setTypes.isEmpty())
    {
        setTypes
            //故障定义
            << ALARM_TYPE_SGL_TEMP_RISE_ALARM //单体温升报警
            << ALARM_TYPE_POWER_LINE_TEMP_RISE_ALARM //动力线温升报警
            << ALARM_TYPE_BMU_BCMU_COM_FAULT //BMU与BCMU通讯故障
            << ALARM_TYPE_BCMU_BA_COM_FAULT //BCMU与BA通讯故障
            << ALARM_TYPE_SGL_VOL_WIRE_FAULT //单体电压采集线故障
            << ALARM_TYPE_BANK_VOL_WIRE_FAULT //总压采集线故障
            << ALARM_TYPE_CUR_WIRE_FAULT //电流采集线故障
            << ALARM_TYPE_TEMP_WIRE_BREAK //温度采集断线
            << ALARM_TYPE_TEMP_SHORT_CIRCUIT //温度采集短路
            << ALARM_TYPE_SGL_VOL_INVALID //单体电压无效
            << ALARM_TYPE_SGL_TEMP_INVALID //单体温度无效
            << ALARM_TYPE_BANK_VOL_INVALID //组端电压无效
            << ALARM_TYPE_ENV_TEMP_INVALID //环境温度无效
            << ALARM_TYPE_CUR_ABNORMITY //组电流异常
            << ALARM_TYPE_POS_RES_INVALID //正极绝缘内阻无效
            << ALARM_TYPE_NEG_RES_INVALID //负极绝缘内阻无效
            << ALARM_TYPE_POS_ADHE_FAULT //总正接触器粘连故障
            << ALARM_TYPE_NEG_ADHE_FAULT //总负接触器粘连故障
            << ALARM_TYPE_PRE_ADHE_FAULT //预充接触器粘连故障
            << ALARM_TYPE_PWLN_TEMP_INVALID //动力线温度无效
            << ALARM_TYPE_HALL_COM_FAULT //霍尔通讯故障
            << ALARM_TYPE_HALL_DAC_FAULT //霍尔采集故障
            << ALARM_TYPE_POS_NOT_CLOSE_FAULT //总正接触器无法闭合故障
            << ALARM_TYPE_NEG_NOT_CLOSE_FAULT //总负接触器无法闭合故障
            << ALARM_TYPE_PRE_NOT_CLOSE_FAULT //预充接触器无法闭合故障
            << ALARM_TYPE_PRE_CHG_FAULT //预充失败
            << ALARM_TYPE_BANK_VOL_DIFF_FAULT //组压采集差故障
            << ALARM_TYPE_POS_FUSE_BLOW //正极熔断器熔断
            << ALARM_TYPE_NEG_FUSE_BLOW //负极熔断器熔断

            << ALARM_TYPE_EX_IO_MODU_CONN_FAULT //扩展IO模块通讯故障
            << ALARM_TYPE_EMER_STOP //紧急停机
            << ALARM_TYPE_FIRE_ALARM //消防报警
            << ALARM_TYPE_WATER_ALARM //水浸报警
            ;
    }

    return setTypes.contains(usType);
}

bool SAlarmCache::IsTypeOfUpLimit()
{
    static QSet<int> setLimit;
    if (setLimit.isEmpty())
    {
        setLimit
            << ALARM_TYPE_BANK_VOL_UP_LIMIT_WARN //组端电压上限预警
            << ALARM_TYPE_CHG_CUR_UP_LIMIT_WARN //充电电流上限预警
            << ALARM_TYPE_DCHG_CUR_UP_LIMIT_WARN //放电电流上限预警
            << ALARM_TYPE_SGL_VOL_UP_LIMIT_WARN //单体电压上限预警
            << ALARM_TYPE_CHG_SGL_TEMP_UP_LIMIT_WARN //充电温度上限预警
            << ALARM_TYPE_DCHG_SGL_TEMP_UP_LIMIT_WARN //放电温度上限预警
            << ALARM_TYPE_SGL_TEMP_UP_LIMIT_WARN //单体温度上限预警
            << ALARM_TYPE_ENV_TEMP_UP_LIMIT_WARN //环境温度上限预警
            << ALARM_TYPE_POWER_LINE_TEMP_UP_LIMIT_WARN //动力线温度上限预警
            << ALARM_TYPE_BANK_SOC_UP_LIMIT_WARN //组端SOC上限预警
            << ALARM_TYPE_PACK_VOL_DIFF_UP_LIMIT_WARN //箱压差上限预警
            << ALARM_TYPE_PACK_TEMP_DIFF_UP_LIMIT_WARN //箱温差上限预警
            << ALARM_TYPE_BANK_VOL_DIFF_UP_LIMIT_WARN //组压采集差上限预警
            << ALARM_TYPE_PACK_VOL_UP_LIMIT_WARN //箱电压上限预警

            //告警定义
            << ALARM_TYPE_BANK_VOL_UP_LIMIT_ALARM //组端电压上限告警
            << ALARM_TYPE_CHG_CUR_UP_LIMIT_ALARM //充电电流上限告警
            << ALARM_TYPE_DCHG_CUR_UP_LIMIT_ALARM //放电电流上限告警
            << ALARM_TYPE_SGL_VOL_UP_LIMIT_ALARM //单体电压上限告警
            << ALARM_TYPE_CHG_SGL_TEMP_UP_LIMIT_ALARM //充电温度上限告警
            << ALARM_TYPE_DCHG_SGL_TEMP_UP_LIMIT_ALARM //放电温度上限告警
            << ALARM_TYPE_SGL_TEMP_UP_LIMIT_ALARM //单体温度上限告警
            << ALARM_TYPE_ENV_TEMP_UP_LIMIT_ALARM //环境温度上限告警
            << ALARM_TYPE_POWER_LINE_TEMP_UP_LIMIT_ALARM //动力线温度上限告警
            << ALARM_TYPE_BANK_SOC_UP_LIMIT_ALARM //组端SOC上限告警
            << ALARM_TYPE_PACK_VOL_DIFF_UP_LIMIT_ALARM //箱压差上限告警
            << ALARM_TYPE_PACK_TEMP_DIFF_UP_LIMIT_ALARM //箱温差上限告警
            << ALARM_TYPE_BANK_VOL_DIFF_UP_LIMIT_ALARM //组压采集差上限告警
            << ALARM_TYPE_PACK_VOL_UP_LIMIT_ALARM //箱电压上限告警

            //保护定义
            << ALARM_TYPE_BANK_VOL_UP_LIMIT_PROT //组端电压上限保护
            << ALARM_TYPE_CHG_CUR_UP_LIMIT_PROT //充电电流上限保护
            << ALARM_TYPE_DCHG_CUR_UP_LIMIT_PROT //放电电流上限保护
            << ALARM_TYPE_SGL_VOL_UP_LIMIT_PROT //单体电压上限保护
            << ALARM_TYPE_SGL_VOL_DOWN_LIMIT_PROT //单体电压下限保护
            << ALARM_TYPE_CHG_SGL_TEMP_UP_LIMIT_PROT //充电温度上限保护
            << ALARM_TYPE_DCHG_SGL_TEMP_UP_LIMIT_PROT //放电温度上限保护
            << ALARM_TYPE_SGL_TEMP_UP_LIMIT_PROT //单体温度上限保护
            << ALARM_TYPE_ENV_TEMP_UP_LIMIT_PROT //环境温度上限保护
            << ALARM_TYPE_POWER_LINE_TEMP_UP_LIMIT_PROT //动力线温度上限保护
            << ALARM_TYPE_BANK_SOC_UP_LIMIT_PROT //组端SOC上限保护
            << ALARM_TYPE_PACK_VOL_DIFF_UP_LIMIT_PROT //箱压差上限保护
            << ALARM_TYPE_PACK_TEMP_DIFF_UP_LIMIT_PROT //箱温差上限保护
            << ALARM_TYPE_BANK_VOL_DIFF_UP_LIMIT_PROT //组压采集差上限保护
            << ALARM_TYPE_PACK_VOL_UP_LIMIT_PROT //箱电压上限保护

            //提示定义
            << ALARM_TYPE_BANK_VOL_UP_LIMIT_TIP //组端电压上限提示
            << ALARM_TYPE_CHG_CUR_UP_LIMIT_TIP //充电电流上限提示
            << ALARM_TYPE_DCHG_CUR_UP_LIMIT_TIP //放电电流上限提示
            << ALARM_TYPE_SGL_VOL_UP_LIMIT_TIP //单体电压上限提示
            << ALARM_TYPE_CHG_SGL_TEMP_UP_LIMIT_TIP //充电温度上限提示
            << ALARM_TYPE_DCHG_SGL_TEMP_UP_LIMIT_TIP //放电温度上限提示
            << ALARM_TYPE_SGL_TEMP_UP_LIMIT_TIP //单体温度上限提示
            << ALARM_TYPE_ENV_TEMP_UP_LIMIT_TIP //环境温度上限提示
            << ALARM_TYPE_POWER_LINE_TEMP_UP_LIMIT_TIP //动力线温度上限提示
            << ALARM_TYPE_BANK_SOC_UP_LIMIT_TIP //组端SOC上限提示
            << ALARM_TYPE_PACK_VOL_DIFF_UP_LIMIT_TIP //箱压差上限提示
            << ALARM_TYPE_PACK_TEMP_DIFF_UP_LIMIT_TIP //箱温差上限提示
            << ALARM_TYPE_BANK_VOL_DIFF_UP_LIMIT_TIP //组压采集差上限提示
            << ALARM_TYPE_PACK_VOL_UP_LIMIT_TIP //箱电压上限提示
            ;
    }

    return setLimit.contains(usType);
}

bool SAlarmCache::IsTypeOfDownLimit()
{
    static QSet<int> setLimit;
    if (setLimit.isEmpty())
    {
        setLimit
            << ALARM_TYPE_BANK_VOL_DOWN_LIMIT_WARN //组端电压下限预警
            << ALARM_TYPE_SGL_VOL_DOWN_LIMIT_WARN //单体电压下限预警
            << ALARM_TYPE_CHG_SGL_TEMP_DOWN_LIMIT_WARN //充电温度下限预警
            << ALARM_TYPE_DCHG_SGL_TEMP_DOWN_LIMIT_WARN //放电温度下限预警
            << ALARM_TYPE_SGL_TEMP_DOWN_LIMIT_WARN //单体温度下限预警
            << ALARM_TYPE_ENV_TEMP_DOWN_LIMIT_WARN //环境温度下限预警
            << ALARM_TYPE_BANK_SOC_DOWN_LIMIT_WARN //组端SOC下限预警
            << ALARM_TYPE_POS_RES_DOWN_LIMIT_WARN //正极绝缘内阻下限预警
            << ALARM_TYPE_NEG_RES_DOWN_LIMIT_WARN //负极绝缘内阻下限预警
            << ALARM_TYPE_PACK_VOL_DOWN_LIMIT_WARN //箱电压下限预警

            //告警定义
            << ALARM_TYPE_BANK_VOL_DOWN_LIMIT_ALARM //组端电压下限告警
            << ALARM_TYPE_SGL_VOL_DOWN_LIMIT_ALARM //单体电压下限告警
            << ALARM_TYPE_CHG_SGL_TEMP_DOWN_LIMIT_ALARM //充电温度下限告警
            << ALARM_TYPE_DCHG_SGL_TEMP_DOWN_LIMIT_ALARM //放电温度下限告警
            << ALARM_TYPE_SGL_TEMP_DOWN_LIMIT_ALARM //单体温度下限告警
            << ALARM_TYPE_ENV_TEMP_DOWN_LIMIT_ALARM //环境温度下限告警
            << ALARM_TYPE_BANK_SOC_DOWN_LIMIT_ALARM //组端SOC下限告警
            << ALARM_TYPE_POS_RES_DOWN_LIMIT_ALARM //正极绝缘内阻下限告警
            << ALARM_TYPE_NEG_RES_DOWN_LIMIT_ALARM //负极绝缘内阻下限告警
            << ALARM_TYPE_PACK_VOL_DOWN_LIMIT_ALARM //箱电压下限告警

            //保护定义
            << ALARM_TYPE_BANK_VOL_DOWN_LIMIT_PROT //组端电压下限保护
            << ALARM_TYPE_SGL_VOL_DOWN_LIMIT_PROT //单体电压下限保护
            << ALARM_TYPE_CHG_SGL_TEMP_DOWN_LIMIT_PROT //充电温度下限保护
            << ALARM_TYPE_DCHG_SGL_TEMP_DOWN_LIMIT_PROT //放电温度下限保护
            << ALARM_TYPE_SGL_TEMP_DOWN_LIMIT_PROT //单体温度下限保护
            << ALARM_TYPE_ENV_TEMP_DOWN_LIMIT_PROT //环境温度下限保护
            << ALARM_TYPE_BANK_SOC_DOWN_LIMIT_PROT //组端SOC下限保护
            << ALARM_TYPE_POS_RES_DOWN_LIMIT_PROT //正极绝缘内阻下限保护
            << ALARM_TYPE_NEG_RES_DOWN_LIMIT_PROT //负极绝缘内阻下限保护
            << ALARM_TYPE_PACK_VOL_UP_LIMIT_PROT //箱电压上限保护
            << ALARM_TYPE_PACK_VOL_DOWN_LIMIT_PROT //箱电压下限保护


            //提示定义
            << ALARM_TYPE_BANK_VOL_DOWN_LIMIT_TIP //组端电压下限提示
            << ALARM_TYPE_SGL_VOL_DOWN_LIMIT_TIP //单体电压下限提示
            << ALARM_TYPE_CHG_SGL_TEMP_DOWN_LIMIT_TIP //充电温度下限提示
            << ALARM_TYPE_DCHG_SGL_TEMP_DOWN_LIMIT_TIP //放电温度下限提示
            << ALARM_TYPE_SGL_TEMP_DOWN_LIMIT_TIP //单体温度下限提示
            << ALARM_TYPE_ENV_TEMP_DOWN_LIMIT_TIP //环境温度下限提示
            << ALARM_TYPE_BANK_SOC_DOWN_LIMIT_TIP //组端SOC下限提示
            << ALARM_TYPE_POS_RES_DOWN_LIMIT_TIP //正极绝缘内阻下限提示
            << ALARM_TYPE_NEG_RES_DOWN_LIMIT_TIP //负极绝缘内阻下限提示
            << ALARM_TYPE_PACK_VOL_DOWN_LIMIT_TIP //箱电压下限提示
            ;
    }

    return setLimit.contains(usType);
}

float SAlarmCache::GetUpDiff()
{
    if (IsTypeOfUpLimit())
    {
        //超上限,则为采集值减设置值
        return fSampVal - fThreVal;
    }
    else
    {
        return 0.0;
    }
}

float SAlarmCache::GetDownDiff()
{
    if (IsTypeOfDownLimit())
    {
        //超下限,则为设置值减采集值
        return fThreVal - fSampVal;
    }
    else
    {
        return 0.0;
    }
}

bool SAlarmCache::IsLevelOfWarn()
{
    return (PARAM_TYPE_WARN == usLevel);
}

bool SAlarmCache::IsLevelOfWarnHC()
{
    return (PARAM_TYPE_WARN_DIFF == usLevel);
}

bool SAlarmCache::IsLevelOfAlarm()
{
    return (PARAM_TYPE_ALARM == usLevel);
}

bool SAlarmCache::IsLevelOfAlarmHC()
{
    return (PARAM_TYPE_ALARM_DIFF == usLevel);
}

bool SAlarmCache::IsLevelOfProt()
{
    return (PARAM_TYPE_PROT == usLevel);
}

bool SAlarmCache::IsLevelOfProtHC()
{
    return (PARAM_TYPE_PROT_DIFF == usLevel);
}

bool SAlarmCache::IsLevelOfTip()
{
    return (PARAM_TYPE_TIP == usLevel);
}

bool SAlarmCache::IsLevelOfTipHC()
{
    return (PARAM_TYPE_TIP_DIFF == usLevel);
}

bool SAlarmCache::IsHasAlarm()
{
    return (1 == usAlmVal);
}

bool SAlarmCache::IsNoAlarm()
{
    return (0 == usAlmVal);
}
